<%@ page import="com.scalar.chiptrack.utils.ConfigManager, java.util.Calendar"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>
<%@ page import="com.scalar.chiptrack.jasper.JasperReports" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/lotsIntransit.do?action=transitinfo" />
<%String chipTracContext = "/" + ConfigManager.getChipTracContext(); %>

<HTML><HEAD><TITLE>ScalarSoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></SCRIPT>

<SCRIPT language="JavaScript">

var dateElement = "";
function openCalendar(dateValue)
{
    dateElement = dateValue;
    newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
    newWindow.moveTo(550,180);
    newWindow.focus();
}
function assignDate(passedValue)
{
    dateElement.value=passedValue;
    window.focus();
}

function selectBaseProduct()
{
	document.lotsIntransitForm.action="<%=chipTracContext%>/lotsIntransit.do?action=transitinfo";
	document.lotsIntransitForm.submit();
}

function getProductsForProcess()
{
	document.lotsIntransitForm.action="<%=chipTracContext%>/lotsIntransit.do?action=transitinfo";
	document.lotsIntransitForm.submit();
}

function validateFromAndToDates()
{
    var formdoc = document.lotsIntransitForm;
    errMsg = '';

    var pa	= document.getElementById("errors")

    if(chkDate(formdoc.fromDate.value,'From-Date','N') == false)
    {
        pa.innerHTML = errMsg;
        formdoc.fromDate.focus();
        return false;
    }

    if(chkDate(formdoc.toDate.value,'To-Date','N') == false)
    {
        pa.innerHTML = errMsg;
        formdoc.toDate.focus();
        return false;
    }

    if(formdoc.fromDate.value!='' && formdoc.toDate.value!='')
    {
        if (!validateDateOut(formatDateAsMMDDYYYY(formdoc.fromDate.value),formatDateAsMMDDYYYY(formdoc.toDate.value)))
        {
            pa.innerHTML = "<li>To Date cannot be less than From Date</li>";
            formdoc.toDate.focus();
            return false;
        }
    }
    return true;
}

function submitForm( reportType ) // 1 for Crystal , 2 for EXCEL
{
    var d = new Date();
    var day = d.getDate();
    var month = d.getMonth()+1;
    var year = d.getFullYear();
    var hour = d.getHours();
    var min = d.getMinutes();
    var sec = d.getSeconds();

    var defaultPrompt = day+"/"+month+"/"+year+":"+hour+":"+min+":"+sec;

    var success;
    success = true;
    success = validateFromAndToDates();
    if(success == false)
    {
       return;
    }
  // @PROCESS_STEP,@PROCESSSTEP_IDS,@BASEPRODUCT_ID,@VENDOR,@FROMDATE,@TODATE ,@SEARCH_PARTNUMBER,@REPORT_FROM,@REPORT_TYPE,@DEFAULT_PROMPT
// processType	product	 products	fromvendor	tovendor 	datefrom   dateto
    if (document.lotsIntransitForm.processName.value == '')
        document.lotsIntransitForm.prompt0.value='0';
    else
        document.lotsIntransitForm.prompt0.value = document.lotsIntransitForm.processName.value;

    if (document.lotsIntransitForm.processStepId.value == '')
        document.lotsIntransitForm.prompt1.value='0';
    else
        document.lotsIntransitForm.prompt1.value = document.lotsIntransitForm.processStepId.value;

    if (document.lotsIntransitForm.baseProductId.value == '')
        document.lotsIntransitForm.prompt2.value='0';
    else
        document.lotsIntransitForm.prompt2.value = document.lotsIntransitForm.baseProductId.value;

    if (document.lotsIntransitForm.vendorName.value == '')
            document.lotsIntransitForm.prompt3.value='0';
        else
            document.lotsIntransitForm.prompt3.value = document.lotsIntransitForm.vendorName.value;

    if (document.lotsIntransitForm.fromDate.value =='')
        document.lotsIntransitForm.prompt4.value='0';
    else
        document.lotsIntransitForm.prompt4.value = document.lotsIntransitForm.fromDate.value;

    if (document.lotsIntransitForm.toDate.value == '')
        document.lotsIntransitForm.prompt5.value='0';
    else
        document.lotsIntransitForm.prompt5.value = document.lotsIntransitForm.toDate.value;

    document.lotsIntransitForm.prompt6.value = '';
    document.lotsIntransitForm.prompt7.value = '0';
    document.lotsIntransitForm.prompt8.value = '0';
    document.lotsIntransitForm.prompt9.value = 'Transit';
    document.lotsIntransitForm.prompt10.value = 'Crystal';
    document.lotsIntransitForm.prompt11.value = defaultPrompt;

    if ( reportType == 2 )
    {
        document.lotsIntransitForm.prompt10.value = 'XLREPORT';
        document.lotsIntransitForm.action = "<%=chipTracContext%>/operationsDataDumpReports.do?action=shipmentReportByDate";
        document.lotsIntransitForm.submit();        
        //var url = '<%=chipTracContext%>/operationsDataDumpReports.do?action=shipmentReportByDate&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8+ '&prompt9=' + prompt9+ '&prompt10=' + prompt10+ '&prompt11=' + prompt11+ '&prompt12=' + prompt12;

    }
    else
    {
        //document.lotsIntransitForm.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/LOTS_INTRANSIT_REPORT.rpt";
        document.lotsIntransitForm.action = "<%=chipTracContext%>/reports/shipmentReport.do?<%=Constants.REQUEST_PARAM_REPORT_NAME%>=<%=JasperReports.LOTS_INTRANSIT_REPORT%>";
        document.lotsIntransitForm.submit();
    }
}

function loadProducts()
{
	document.lotsIntransitForm.action="<%=chipTracContext%>/lotsIntransit.do?action=transitinfo";
	document.lotsIntransitForm.submit();
}

function clearErrors()
{
    var pa=document.getElementById("errors");
    pa.innerHTML = "";
}

</script>
</HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<html:form name="lotsIntransitForm" type="com.scalar.chiptrack.operations.reports.forms.TransitForm" action="/lotsIntransit.do?action=transitinfo">
<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->


<TABLE cellSpacing=0 cellPadding=0 width="100%" border="0">
    <TR>
        <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
            <!-- Side Navigation start -->
            <%@ include file="/jsp/operations/reports_side_menu.jsp" %>
            <!-- end of the side navigations -->
        </td>
        <TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
        <TD bgcolor="#ffffff">

            <input type="hidden" name="prompt0">
            <input type="hidden" name="prompt1">
            <input type="hidden" name="prompt2">
            <input type="hidden" name="prompt3">
            <input type="hidden" name="prompt4">
            <input type="hidden" name="prompt5">
            <input type="hidden" name="prompt6">
            <input type="hidden" name="prompt7">
            <input type="hidden" name="prompt8">
            <input type="hidden" name="prompt9">
            <input type="hidden" name="prompt10">
            <input type="hidden" name="prompt11">
        </TD>
        <TD valign="top" width="100%">
            <table border="0" width="85%" align="center">
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr><td colspan="6" width="100%" align="center" class="NArialW">Shipment Report by Date</TD></TR>
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr>
                    <td width="5%">&nbsp;</td>
                    <td width="85%" colspan="5" align="left">
                        <b><font face="Verdana" size="-5" align="center" color="#ff0000" id="errors"></font></b>&nbsp;
                    </td>
                </tr>
                <TR>
                        <TD width="5%">&nbsp;</TD>
                        <TD width="20%" class=NArialL style="width:150px">Process Type</TD>
                        <TD width="25%" class=NArialL >
                        <html:select property="processName" name="lotsIntransitForm" styleClass="txfield" onchange="getProductsForProcess()" >
                            <%--<html:option value="0">Select Process Type</html:option>--%>
                            <html:options collection="processTypeList" property="value" labelProperty="label"/>
                        </html:select>
                        </TD>
                        <TD width="5%">&nbsp;</TD>
                        <TD width="20%" class=NArialL>Vendor Name</TD>
                        <TD width="25%" class=NArialL>
                         <html:select property="vendorName" name="lotsIntransitForm" styleClass="txfield">
                             <html:option value="0">All Vendors</html:option>
                            <html:options collection="locationList" property="label" labelProperty="label"/>
                         </html:select>
                        </TD>
                </TR>
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <TR>
                        <TD width="5%">&nbsp;</TD>
                        <TD width="15%" class=NArialL style="width:150px" >Base Product Name</TD>
                        <TD width="25%" class=NArialL >
                            <html:select property="baseProductId" name="lotsIntransitForm" styleClass="txfield" onchange="selectBaseProduct()" >
                                <html:option value="0">All Base Products</html:option>
                                <html:options collection="baseProductList" property="value" labelProperty="label"/>
                            </html:select>
                        </TD>
                        <TD width="5%">&nbsp;</TD>
                        <TD width="20%" class=NArialL >Products</TD>
                        <TD width="25%" class=NArialL>
                            <html:select property="processStepId" name="lotsIntransitForm" styleClass="txfield" >
                                <html:option value="0">All Products</html:option>
                                <html:options collection="partNumberList" property="value" labelProperty="label"/>
                            </html:select>
                        </TD>
                </TR>
               <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=8></td></tr>
                <TR>
                    <TD width="5%">&nbsp;</TD>
                    <TD width="20%" class=NArialL style="width:100px">From-Date</TD>
                    <TD width="25%" class=NArialL><font>
                        <html:text property="fromDate" styleClass="txfield" size="16" maxlength="10"/>
                        <a href="javascript:openCalendar(document.lotsIntransitForm.fromDate)">
                        <img onMouseOver="window.status='Click here to select From date';return true" onMouseOut="window.status='';return true" border="0" align='center' title="Click here to Select From Date"
                        src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
                    </TD>
                    <TD width="5%">&nbsp;</TD>
                    <TD width="20%" class=NArialL style="width:100px">To-Date</TD>
                    <TD width="25%" class=NArialL>
                        <html:text property="toDate" styleClass="txfield" size="16" maxlength="10"/>
                        <a href="javascript:openCalendar(document.lotsIntransitForm.toDate)">
                        <img onMouseOver="window.status='Click here to select To date';return true" onMouseOut="window.status='';return true" border="0" align='center' title="Click here to Select To Date"
                        src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
                    </TD>
                </TR>
                <tr>
                    <td colspan="5">&nbsp;</td>
                    <td colspan= "1" align="left" valign="top">
                    <a class="NArialL" href="javascript:submitForm(2)" onMouseOver="window.status='Click here to Export to Excel';return true" onMouseOut="window.status='';return true" title='Click here to Export to Excel' >Export to Excel</a>
                    </td>
                </tr>
                <tr><td colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>&nbsp;</td></tr>
                <tr>
                    <td width="30%" colspan="3" align="right"><a href="javascript:submitForm(1)">
                        <img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onMouseOver="window.status='Click to Generate Report';return true" onmouseout="window.status='';return true" title="Click here to Generate Report"/></a>
                    </td>
                    <td width="70%"  colspan="3" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="javascript:document.lotsIntransitForm.reset();">
                    <img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onMouseOver="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"/></a>
                    </td>
                    <%--<td width="30%" colspan="3" align="right"><input type="image" onclick="javascript:submitForm(1)"  border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Generate Report';return true"onmouseout="window.status='';return true"title="Click here to Generate Report"></td>
                    <td width="70%"  colspan="3" align="left">
                        &nbsp;&nbsp;
                        <a href="javascript:document.lotsIntransitForm.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true"title="Click here to Reset"></a>
                    </td>--%>
                </tr>
            </table>
            <BR><BR><BR>

        </TD>
        <TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
    </TR>
</TABLE>
</html:form>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>

<%--
<%
    }
    catch( Exception e )
    {
        e.printStackTrace();
    }
%>--%>
